package com.liboteng.springboot.controller;


import com.liboteng.springboot.model.Person;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class HomeController {

    @RequestMapping("home")
    public String home(Model model){
        List<Person> personList = new ArrayList<>();
        for (int i = 0; i < 10; i++){
            Person person = new Person();
            person.setAge(i*10);
            person.setId(i);
            person.setName("伞兵" + i + "号"); // 修正字符串格式
            personList.add(person); // 添加到列表中
        }
        String name = "DAVID";
        model.addAttribute("name", name);
        model.addAttribute("personList", personList);
        return "home.html";
    }
}
